package com.chang.search.controller;

import com.chang.search.service.MallSearchService;
import com.chang.search.vo.SearchParam;
import com.chang.search.vo.SearchResult;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author: changzhenxi
 * @date: 2024年09月13日 10:49
 * @Version: 1.0
 * @description:
 */
@Controller
public class SearchController {

    @Resource
    MallSearchService searchService;

    /**
     * @param: [searchParam] 自动将页面提交过来的所有请求查询参数封装成指定的searchParam包装对象
     * @return: java.lang.String
     * @author changzhenxi
     * @date 2024/9/24 - 10:57
     * @history 2024/9/24 - 10:57 changzhenxi create
     */
    @GetMapping("/list.html")
    public String listPage(SearchParam searchParam, Model model) {
        // 根据传递过来的页面的检索参数,去es中检索商品
        SearchResult result = searchService.search(searchParam);
        model.addAttribute("result", result);
        return "list";
    }
}
